<template>
<!-- 收到的评论 -->
  <div class="getin">
    <div class="content" v-if="receivedComment.length > 0">
      <div class="item" v-for="item in receivedComment" :key="item.id">
        <div class="left">
          <p class="commentContent"><span>贝贝回复我的评论：</span>{{item.parentName}}</p>
          <p class="myComment">我的评论：{{item.commentName}}</p>
          <div class="bottom">
            <div class="bottomLeft">
              <span class="spanStyle"></span>
            <span class="projectName" v-if="item.type === 1">项目：{{item.projectName}}</span>
            <span class="projectName" v-else-if="item.type === 2">任务：{{item.taskName}}</span>
            <span class="projectName" v-else-if="item.type === 3">评论：我是评论标题</span>
            <span class="projectName" v-else-if="item.type === 4">任务结果：我是任务结果标题</span>
            <span class="projectName" v-else>教学资料：我是教学资料标题</span>
            <span :class="item.taskPriority <= 100 ? 'LvOne' : item.taskPriority > 100 && item.taskPriority <= 200 ? 'LvTwo' : 'LvThree' ">LV{{item.taskPriority}}</span>
            <div class="progress" v-if="item.type === 1">
              <span :class="item.projectStatus === 1 ? 'waiting' : item.projectStatus === 2 && item.projectStatus === 3 ? 'going' : 'competed'"></span>
              <span v-if="item.projectStatus === 1">待开始</span>
              <span v-else-if="item.projectStatus === 2">进行中</span>
              <span v-else>已结束</span>
            </div>
            <div class="progress" :class="item.taskStatus === 1 ? 'waiting' : item.taskStatus === 2 && item.taskStatus === 3 ? 'going' : 'competed'" v-else>
              <span :class="item.taskStatus === 1 ? 'waiting' : item.taskStatus === 2 && item.taskStatus === 3 ? 'going' : 'competed'"></span>
              <span v-if="item.taskStatus === 1">未开始</span>
              <span v-else-if="item.taskStatus === 2">进行中</span>
              <span v-else>已完成</span>
            </div>
            </div>
            <div class="bottomRight">
              <span>{{item.createTime}}</span>
            </div>
          </div>
        </div>
        <div class="right" @click="toReply(item)">
          <el-tooltip effect="dark" content="去回复" placement="top">
          <img src="@/assets/sendComment.png" alt=""  />
          </el-tooltip>
        </div>
      </div>
    </div>
    <div v-else>
      <span>暂无评论</span>
    </div>
  </div>
</template>

<script>
import { getReceivedComment } from '@/api/comment/comment.js';
export default {
  name: 'getin',
  data() {
    return {
      receivedComment: []
    };
  },
  created() {
    this.getComment();
  },
  methods: {
    async getComment() {
      const res = await getReceivedComment(sessionStorage.getItem('userid'));
      console.log(res);
      this.receivedComment = res.data;
    },
    toReply(val) {
      // console.log(11);
      console.log(val);
      if (val.type === 1) {
        // 跳转到项目
        this.$router.push('/projectdetail');
        localStorage.setItem('projectId', val.id);
      } else if (val.type === 2) {
        // 跳转到任务
        localStorage.setItem('taskId', val.id);
        this.$router.push('/misinfo&intro');
      }
    }
  }
};
</script>

<style lang="less" scoped>
.getin{
  width: 100%;
  background-color: #FFF;
  border-radius: 0 5px 5px 5px;
  box-shadow: 1px -2px 3px 0px rgba(153, 153, 153, 0.5), 1px 2px 3px 0px rgba(153, 153, 153, 0.5);
  padding: 40px 20px;
  box-sizing: border-box;
  .content{
    overflow-y: scroll;
    height: 900px;
    width: 100%;
    .item{
    // width: 1809px;
    width: 99%;
    height: 175px;
    background: #FFFFFF;
    border: 1px solid #E6EBFF;
    margin-bottom: 20px;
    padding: 20px 30px;
    padding-right: 0;
    display: flex;
    overflow-y: scroll;
    box-sizing: border-box;
    .left{
      width: 90%;
      box-sizing: border-box;
      font-size: 14px;
      border-right: 1px solid #E6EBFF;
      padding-right: 30px;
      p{
      margin: 0;
      padding: 0;
      }
      .commentContent{
        font-size: 14px;
        color: #333333;
      }
      .myComment{
        font-size: 14px;
        font-weight: 400;
        color: #555555;
        margin-top: 20px;
        box-sizing: border-box;
      }
      .bottom{
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        font-weight: 400;
        color: #444444;
        box-sizing: border-box;
        .bottomLeft{
          display: flex;
          align-items: center;
          .spanStyle{
          width: 5px;
          height: 15px;
          background: linear-gradient(180deg, #1160CF 0%, #CD06BF 100%);
          border-radius: 3px;
          margin-right: 5px;
        }
        .span{
          display: inline-block;
        }
        .projectName{
          margin-right: 30px;
        }
        // .level{
        //   margin-right: 30px;
        // }
        .LvOne{
          text-align: center;
          color: white;
          border-radius: 10px;
          width: 60px;
          height: 20px;
          margin-right: 30px;
          background: #c5f5d1;
      }
      .LvTwo  {
          text-align: center;
          color: white;
          border-radius: 10px;
          width: 60px;
          height: 20px;
        margin-right: 30px;
        background: #f7cbd2;
      }
      .LvThree {
          text-align: center;
          color: white;
          border-radius: 10px;
          width: 60px;
          height: 20px;
          margin-right: 30px;
          background: #cbd5f5;
      }
        .progress{
          span{
            display: inline-block;
          }
          .waiting{
              width: 10px;
              height: 10px;
              border-radius: 50%;
              background-color: #555555;
            }
            .going{
              width: 10px;
              height: 10px;
              border-radius: 50%;
              background-color: #FFD167;
            }
            .competed{
              width: 10px;
              height: 10px;
              border-radius: 50%;
              background-color: #3EA528;
            }
        }
        .progress.waiting{
          color: #555555;
        }
        .progress.going{
          color: #FFD167;
        }
        .progress.competed{
          color: #3EA528;
        }
        }
      }
    }
    .right{
      width: 200px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      img{
        height: 40px;
        width: 40px;
        // line-height: ;
      }
    }
  }
  }
}
</style>
